<template>
  <nav class="navigation">
    <div class="nav-brand">
      <router-link to="/" class="brand-link">
        <span class="brand-icon">🏠</span>
        <span class="brand-text">AIcemeric</span>
      </router-link>
    </div>
    
    <div class="nav-menu">
      <router-link 
        v-for="item in menuItems" 
        :key="item.name"
        :to="item.path"
        class="nav-item"
        :class="{ active: isActive(item.path) }"
      >
        <i :class="item.icon"></i>
        <span>{{ item.title }}</span>
      </router-link>
    </div>
    
    <div class="nav-actions">
      <div class="search-box">
        <i class="search-icon"></i>
        <input type="text" placeholder="搜索..." v-model="searchQuery" />
      </div>
      
      <button class="nav-btn notification-btn" @click="showNotifications">
        <i class="notification-icon"></i>
        <span v-if="notificationCount > 0" class="notification-badge">{{ notificationCount }}</span>
      </button>
      
      <button class="nav-btn" @click="showMessages">
        <i class="message-icon"></i>
      </button>
      
      <button class="nav-btn" @click="toggleTheme">
        <i class="icon-theme"></i>
      </button>
      
      <div class="user-avatar" @click="showUserMenu">
        <i class="user-icon"></i>
      </div>
    </div>
  </nav>
</template>

<script>
export default {
  name: 'AppNavigation',
  data() {
    return {
      searchQuery: '',
      notificationCount: 3, // 示例通知数量
      menuItems: [
        {
          name: 'monitoring',
          title: '监控平台',
          path: '/monitoring',
          icon: 'icon-dashboard'
        },
        {
          name: 'realtime',
          title: '实时数据',
          path: '/monitoring/realtime',
          icon: 'icon-realtime'
        },
        {
          name: 'history',
          title: '历史数据',
          path: '/monitoring/history',
          icon: 'icon-history'
        },
        {
          name: 'trend',
          title: '趋势分析',
          path: '/monitoring/trend',
          icon: 'icon-trend'
        },
        {
          name: 'heatmap',
          title: '压力热图',
          path: '/monitoring/heatmap',
          icon: 'icon-heatmap'
        }
      ]
    }
  },
  methods: {
    isActive(path) {
      return this.$route.path === path || this.$route.path.startsWith(path + '/')
    },
    toggleTheme() {
      // 主题切换逻辑
      document.body.classList.toggle('dark-theme')
    },
    showNotifications() {
      // 显示通知列表
      console.log('显示通知')
      // 这里可以打开通知面板
    },
    showMessages() {
      // 显示消息列表
      console.log('显示消息')
      // 这里可以打开消息面板
    },
    showUserMenu() {
      // 显示用户菜单
      console.log('显示用户菜单')
      // 这里可以打开用户菜单
    }
  }
}
</script>

<style scoped>
.navigation {
  background: #FFFFFF;
  border-bottom: 1px solid #E5E7EB;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-brand {
  margin-right: 48px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: rgba(0, 0, 0, 0.88);
  font-weight: 600;
  font-size: 18px;
}

.brand-icon {
  font-size: 24px;
}

.brand-text {
  background: linear-gradient(135deg, #1677FF, #722ED1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-menu {
  display: flex;
  gap: 32px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  color: rgba(0, 0, 0, 0.65);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
}

.nav-item:hover {
  color: #1677FF;
  background: rgba(22, 119, 255, 0.06);
}

.nav-item.active {
  color: #1677FF;
  background: rgba(22, 119, 255, 0.1);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -17px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: #1677FF;
  border-radius: 1px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  background: #FFFFFF;
  border: 1px solid #D9D9D9;
  border-radius: 6px;
  padding: 6px 12px;
  width: 200px;
  gap: 8px;
  transition: all 0.3s ease;
}

.search-box:focus-within {
  border-color: #1677FF;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
}

.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.88);
}

.search-box input::placeholder {
  color: rgba(0, 0, 0, 0.45);
}

.search-icon::before {
  content: "🔍";
  font-size: 14px;
  color: rgba(0, 0, 0, 0.45);
}

.nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: rgba(0, 0, 0, 0.65);
  position: relative;
}

.nav-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.88);
}

.notification-btn {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #FF4D4F;
  color: white;
  font-size: 10px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1677FF, #722ED1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 4px;
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.3);
}

/* 图标样式 */
.icon-dashboard::before { content: "📊"; }
.icon-realtime::before { content: "⚡"; }
.icon-history::before { content: "📈"; }
.icon-trend::before { content: "📉"; }
.icon-heatmap::before { content: "🗺️"; }
.icon-theme::before { content: "🌙"; }
.notification-icon::before { content: "🔔"; }
.message-icon::before { content: "💬"; }
.user-icon::before { 
  content: "👤"; 
  color: white;
  font-size: 16px;
}

/* 响应式设计 */
@media (max-width: 992px) {
  .navigation {
    padding: 0 16px;
  }
  
  .nav-brand {
    margin-right: 24px;
  }
  
  .nav-menu {
    gap: 16px;
  }
  
  .nav-item span {
    display: none;
  }
  
  .nav-item {
    padding: 8px;
    min-width: 36px;
    justify-content: center;
  }
  
  .search-box {
    width: 160px;
  }
}

@media (max-width: 768px) {
  .navigation {
    padding: 0 12px;
    height: 56px;
  }
  
  .brand-text {
    display: none;
  }
  
  .nav-menu {
    gap: 8px;
  }
  
  .nav-actions {
    gap: 8px;
  }
  
  .search-box {
    width: 120px;
  }
  
  .nav-btn, .user-avatar {
    width: 32px;
    height: 32px;
  }
  
  .user-avatar {
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  .search-box {
    display: none;
  }
  
  .nav-actions {
    gap: 6px;
  }
}
</style>
